#pragma once
#include <vector>
#include <thread>
#include <iostream>

template<class T>
void print(T vValue)
{
    std::cout << vValue << std::endl;
}

template<class T>
void printVec(T vValueSet)
{
    for (auto& Value : vValueSet)
        std::cout << Value << " ";
    std::cout << std::endl;
}

template<class T>
bool isSameVector(const std::vector<T>& vLeft, const std::vector<T>& vRight)
{
    if (vLeft.size() != vRight.size())
        return false;
    for (int i = 0; i < vLeft.size(); i++)
        if (vLeft[i] != vRight[i])
            return false;

    return true;
}

template<class T>
bool isOrdered(const std::vector<T>& vDataSet)
{
    if (vDataSet.empty() || vDataSet.size() == 1)
        return false;

    bool IsGreater;
    bool AllEqual = true;
    for (int i = 0; i < vDataSet.size() - 1; i++)
    {
        if (vDataSet[i] == vDataSet[i + 1])
            continue;
        else
        {
            AllEqual = false;
            IsGreater = vDataSet[i] < vDataSet[i + 1] ? true : false;
            break;
        }
    }
    if (AllEqual)
        return false;

    for (int i = 0; i < vDataSet.size() - 1; i++)
    {
        if (IsGreater && vDataSet[i] > vDataSet[i + 1])
            return false;
        if (!IsGreater && vDataSet[i] < vDataSet[i + 1])
            return false;
    }

    return true;
}

static std::chrono::system_clock::time_point Begin;
inline void timeBegin()
{
    Begin = std::chrono::system_clock::now();
}

inline float timeEnd()     // return elapsed time
{
    auto End = std::chrono::system_clock::now();
    return float(std::chrono::duration_cast<std::chrono::microseconds>(End - Begin).count());
}

static _CrtMemState MemBegin;

inline void memBegin()
{
    _CrtMemCheckpoint(&MemBegin);
}

inline bool memEnd()       // return true if memory leaks
{
    _CrtMemState MemEnd, MemDifference;
    _CrtMemCheckpoint(&MemEnd);
    return _CrtMemDifference(&MemDifference, &MemBegin, &MemEnd);
}
